package org.huangrui.spark.scala.core.rdd.operate.transform

import org.apache.spark.{SparkConf, SparkContext}

/**
 * @Author hr
 * @Create 2024-10-17 15:41 
 */
object Spark08_Operate_Transform_KV_1 {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf().setMaster("local[*]").setAppName("spark")
    val sc = new SparkContext(conf)
    val nums = List(1, 2, 3, 4)
    // TODO 单值类型数据可以和KV类型进行转换
    sc.parallelize(nums,2).map((x: Int) => (x, x * 2))
      .mapValues((v: Int) => v * 2)
      .collect().foreach(println)

    sc.stop()
  }
}
